//
//  MODepthDoDetailViewController.m
//  MobileOffice
//
//  Created by 冰冰 on 2019/6/26.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#import "MODepthDoDetailViewController.h"
#import "MODepthDoDetail_Text_MainViewController.h"
#import "MODepthDoDetail_Text_OtherViewController.h"
#import "MODepthDoDetail_IdeaViewController.h"

@interface MODepthDoDetailViewController ()<SNPageTabViewDelegate>

@property(nonatomic,strong)SNPageTabView *pageTabView;

@property(nonatomic,strong)MODepthDoDetail_Text_MainViewController *title_1VC;

@property(nonatomic,strong)MODepthDoDetail_Text_OtherViewController *title_2VC;

@end

@implementation MODepthDoDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"公文详情";
    
    [self creatSegumentView];
    
    if ([self.waitModel.wdlx isEqualToString:@"公告审批表"]) {
        [self getData];
    }
}

-(void)creatSegumentView
{
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.title_1VC = [[MODepthDoDetail_Text_MainViewController alloc] init];
    self.title_1VC.waitModel = self.waitModel;
    self.title_1VC.view.backgroundColor = [UIColor whiteColor];
    
    self.title_2VC = [[MODepthDoDetail_Text_OtherViewController alloc] init];
    self.title_2VC.waitModel = self.waitModel;
    self.title_2VC.view.backgroundColor = [UIColor whiteColor];
    
    MODepthDoDetail_IdeaViewController *title_3VC = [[MODepthDoDetail_IdeaViewController alloc] init];
    title_3VC.view.backgroundColor = [UIColor whiteColor];
    
    [self addChildViewController:self.title_1VC];
    [self addChildViewController:self.title_2VC];
//    [self addChildViewController:title_3VC];
    
    _pageTabView = [[SNPageTabView alloc] initWithChildControllers:self.childViewControllers childTitles:@[@"正文", @"附件"]];
    _pageTabView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-StatusBarAndNavigationBarHeight);
    _pageTabView.tabSize = CGSizeMake(SCREEN_WIDTH, 41);
    _pageTabView.tabItemFont = FONT_SIZE(14);
    _pageTabView.unSelectedColor = KBlackColor_919395;
    _pageTabView.selectedColor = KBlackColor_2A2A2A;
    _pageTabView.tabBackgroundColor = [UIColor whiteColor];
    _pageTabView.bodyBounces = NO;
    _pageTabView.titleStyle = SNPageTabTitleStyleDefault;
    _pageTabView.indicatorStyle = SNPageTabIndicatorStyleFollowText;
    _pageTabView.indicatorHeight = 2;
    _pageTabView.delegate = self;
    _pageTabView.selectedTabIndex = 0;
    _pageTabView.lineView.hidden = YES;
    [self.view addSubview:_pageTabView];
    
}

-(void)getData
{
    NSString *url = [NSString stringWithFormat:@"%@/%@?authorization=%@",JNFB_ODPSJNFBYBDETAIL_URL,self.waitModel.key,[NSString URLEncodedString:[MOUser sharedMOUser].token]];
    
    [PPNetworkHelper GET:url parameters:@{} success:^(id responseObject) {
        NSLog(@"公告%@",responseObject);
        
        if ([responseObject[@"status"] integerValue]==1) {
            self.waitModel.nameStr = responseObject[@"data"][@"bt"];
            self.waitModel.content = responseObject[@"data"][@"zw"];
            self.waitModel.fileList = responseObject[@"data"][@"fjList"];
            self.waitModel.ngr = responseObject[@"data"][@"ngr"];
            
            self.title_1VC.waitAgainModel = self.waitModel;
            self.title_2VC.waitAgainModel = self.waitModel;
        }
        
    } failure:^(NSError *error) {
        NSLog(@"公告%@",[error localizedDescription]);
    }];

}


@end
